package com.enjoyor.health.HGPT.service;

import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson2.JSONObject;
import com.enjoyor.health.HGPT.core.entity.FileInfo;
import com.enjoyor.health.HGPT.core.service.IFileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author Zhu Min
 * @date 2023/11/27 14:15
 */
@Service
public class BizFileService {

    @Autowired
    private IFileInfoService fileInfoService;

    public FileInfo saveFileInfo(String fileName, String originalName, Integer type, Integer status){
        FileInfo fileInfo = new FileInfo();
        fileInfo.setFileId(IdUtil.simpleUUID());
        fileInfo.setFileName(fileName);
        fileInfo.setFileOriginalName(originalName);
        fileInfo.setStatus(status);
        fileInfo.setFileType(type);
        fileInfo.setStorageTime(LocalDateTime.now());
        fileInfoService.save(fileInfo);
        return fileInfo;
    }

    public FileInfo findById(String fileId){
        return fileInfoService.getById(fileId);
    }

}
